
var _Area_Code ="0";
var _url;
var normalColor = "#5FB878";
var alarmColor = "#FF5722";
function GetListData(url)
{
	this._url = url;
	var Area_Code = GetQueryVariable("Area_Code")+"";
	if(Area_Code!="false")
	{
		_Area_Code = Area_Code.replace(/^\s+|\s+$/g,"");
	}
    url = url+"Area/GetList?Area_Code="+_Area_Code;
	$.get(url, function(data){
			 if(data.data.length>0)
			 {
				
				 for(var i=0;i<data.data.length;i++)
				 {
					  var   Area_ID  = data.data[i].Area_ID;
					  var   Area_Type  = data.data[i].Area_Type;
					  var   Area_Code  = data.data[i].Area_Code;
					  var   JsonData  = data.data[i].JsonData;
					  var JsonData = JSON.parse(JsonData);
					  var LngLatArray = [];
					  for(var k=0;k<JsonData.length;k++)
					  {
						  var lngLat = new AMap.LngLat(JsonData[k].lng,JsonData[k].lat);
						  LngLatArray.push(lngLat);
					  }
					   var _polygon = createPolygon(Area_ID,LngLatArray,Area_Type==0?normalColor:alarmColor);
					   
					   polygonEditor = createEditor(Area_ID,_polygon);
					   polygonEditor.close();
					  
				 }
			 }
	});
}

function Save(json)
{
	var url = _url +"Area/Add";
	
	$.post(url, { Area_Type: playerUIApp.isDrawType?1:0, Area_Code: _Area_Code,JsonData:json},
		  function(data){
			 var newID =  data.data;
			 SaveCallBack(newID);
		  });
			  
}

function Edit(Area_ID,json)
{
	var url = _url +"Area/Edit/"+Area_ID;
	$.post(url, { Area_ID: Area_ID,JsonData:json},
				function(data){
				 //layer.alert("删除成功");
	          });
}
function Delete(Area_ID)
{
	var url = _url +"Area/Delete/"+Area_ID;
	$.post(url, function(data){
				 layer.alert("删除成功");
	          });
}